package com.zsk.shop.api.txim;

import com.zsk.shop.common.constant.Constant;
import com.tencentcloudapi.common.Credential;
import com.tencentcloudapi.common.exception.TencentCloudSDKException;
import com.tencentcloudapi.common.profile.ClientProfile;
import com.tencentcloudapi.common.profile.HttpProfile;
import com.tencentcloudapi.faceid.v20180301.FaceidClient;
import com.tencentcloudapi.faceid.v20180301.models.BankCard2EVerificationRequest;
import com.tencentcloudapi.faceid.v20180301.models.BankCard2EVerificationResponse;
import com.tencentcloudapi.faceid.v20180301.models.IdCardVerificationResponse;

/**
 * @author Ys
 * @date 2021年12月13日 10:21
 */
public class TencentBankCard2EVerification {

    public static String bankCard2EVerification(String trueName, String bankCardId) {
        String result = "-1";
        try {
            Credential cred = new Credential(Constant.VERIFICATION_SECRET_ID, Constant.VERIFICATION_SECRET_KEY);
            HttpProfile httpProfile = new HttpProfile();
            httpProfile.setEndpoint("faceid.tencentcloudapi.com");
            ClientProfile clientProfile = new ClientProfile();
            clientProfile.setHttpProfile(httpProfile);
            FaceidClient client = new FaceidClient(cred, "ap-shanghai", clientProfile);
            BankCard2EVerificationRequest req = new BankCard2EVerificationRequest();
            req.setName(trueName);
            req.setBankCard(bankCardId);
            BankCard2EVerificationResponse resp = client.BankCard2EVerification(req);

            System.out.println(IdCardVerificationResponse.toJsonString(resp));
            result = resp.getResult();
        } catch (TencentCloudSDKException e) {
            System.out.println(e.toString());
        }
        return result;
    }
}
